import javax.swing.text.rtf.RTFEditorKit;
import java.util.zip.ZipEntry;

public class EulerProblem4 {


    boolean isItPalindrome(int possiblePalindrome){
        String strPossiblePalindrome = new Integer(possiblePalindrome).toString();
//        System.out.println(strPossiblePalindrome);
        char []ch=     strPossiblePalindrome.toCharArray();
//        System.out.println(ch);
        char []ch1 = new char[ch.length];
        for(int i=0;i<ch.length;i++){
            ch1[i]=ch[ch.length-i-1];
//            System.out.println(ch1);
        }
//        System.out.println(strPossiblePalindrome);
        for(int i=0;i<ch.length;i++){
//         System.out.println(ch[i]+ "  "+ ch1[i]);
//         System.out.println(ch1[ch1.length-i-1]);
            if(ch[i]!=ch1[i]) {
                return false;
            }
        }

        return true;
    }

    public static void main(String []arg){
//             System.out.println(new EulerProblem4().isItPalindrome(111));
//            System.out.println(new StringBuffer(arg[0]).reverse());
        System.out.println(new EulerProblem4().largestPalindromeFinder());
    }

    public  int largestPalindromeFinder() {
        int z=0;
        for(int i=999;i>99;i--){
            for (int j=999;j>99;j--)  {
                  int k=i*j;
                if(new EulerProblem4().isItPalindrome(i*j)&& k>z) {
                   z=k;

//                 System.out.println("i "+i+" j "+j+ "i*j "+i*j);
                }
            }
        }
        return z;
    }

}
